<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form method="get" id="save" class="form-horizontal">
                        <input type="hidden" class="form-control" id="id" name="id">
                        <div class="form-group"><label class="col-sm-3 control-label">市内价格(公里/元)</label>
                            <div class="col-sm-7"><input type="number" class="form-control" id="city" name="city"></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-3 control-label">市内超出距离(公里)</label>
                            <div class="col-sm-7"><input type="number" class="form-control" id="c_distance" name="c_distance">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-3 control-label">市内超出价格(公里/元)</label>
                            <div class="col-sm-7"><input type="number" class="form-control" id="city_e" name="city_e"></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-3 control-label">跨城价格(公里/元)</label>

                            <div class="col-sm-7"><input type="number" class="form-control" id="cross_city" name="cross_city"></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-3 control-label">跨城超出距离(公里)</label>
                            <div class="col-sm-7"><input type="number" class="form-control" id="cross_distance" name="cross_distance"></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group"><label class="col-sm-3 control-label">跨城超出价格(公里/元)</label>
                            <div class="col-sm-7"><input type="number" class="form-control" id="cross_city_e" name="cross_city_e"></div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-6">
                                <button class="btn btn-primary" type="button" onclick="edit()">保存</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="js/fromToJson.js"></script>
<script>
    function getPriceInfo(){
        $.getJSON({
            url: bathpath + "/systemSetup/getPriceInfo",
            type: 'post',
            contentType: "application/json"
        }).done(function(data) {
            if (ajaxdatacheck(data)) {
                if (data.code == 1) {
                    $('#id').val(data.content.id)
                    $('#city').val(data.content.city)
                    $('#city_e').val(data.content.city_e)
                    $('#c_distance').val(data.content.c_distance)
                    $('#cross_city').val(data.content.cross_city)
                    $('#cross_city_e').val(data.content.cross_city_e)
                    $('#cross_distance').val(data.content.cross_distance)
                } else {
                    swal("操作提示", "服务器错误请联系管理员","error");
                }
            }
        })
            .fail(function(e) {
                console.error(e)
            })
            .always(function() {
                console.log('done!')
            })
    }
    getPriceInfo();

    function edit() {
        var json = $('#save').serialize();//获取值
        json= decodeURIComponent(json,true);//防止中文乱码
        var param=DataDeal.formToJson(json);//转化为json
        $.getJSON({
            url: bathpath + "/systemSetup/editPrice",
            type: 'post',
            contentType: "application/json",
            data: param
        }).done(function(data) {
            if (ajaxdatacheck(data)) {
                if (data.code == 1) {
                    swal("操作提示", "操作成功","success");
                } else {
                    swal("操作提示", "操作失败","error");
                }
            }
        })
            .fail(function(e) {
                console.error(e)
            })
            .always(function() {
                console.log('done!')
            })
    }
</script>